<?php

	/**
	* @author zhouguoyan
	* @desc
	**/	
	
class HtmlController extends AppController {
	var $name='Html';
	var $uses=array('Html');
 	var $access = array ('html_add'=>array('role' => array('System')),
					     'html_confirm'=>array('role' => array('System')),
					     'html_doadd'=>array('role' => array('System'))
					      );  
	/**
	* @author zhouguoyan
	* @desc 进入添加页面
	**/	
	
	function html_add(){
		$html_info=$this->Session->read('html_info');
		if(!empty($html_info)){
			$this->data=$html_info;
		}
	}
	
	/**
	* @author zhouguoyan
	* @desc 验证
	**/	
	function html_confirm(){
		$message = $this->Html->valid($this->Valid,$this->data);

		$this->Session->write('html_info',$this->data);

		if(!empty($message)){
			$this->set('message',$message);
			
			$this->render('html_add');
			exit;
		}

	}	
	
	/**
	* @author zhouguoyan
	* @desc 把数据添加数据库
	**/	
	function html_doadd(){
		$id=$this->data['Html']['id'];
		if( $id==null){
			if($this->Session->check('html_info')){
				$this->Html->save($this->Session->read('html_info'));
			}
		}
		else{
				$this->Html->save($this->Session->read('html_info'));
		}		
		$this->Session->del('html_info');
		
		
	}
}
?>
